from trader import AStockTrader
from strategy import MAStrategy
from backtest import Backtest
from settings import Constant 


if __name__ == '__main__':
    # 初始化
    token = Constant.TUSHARE_TOKEN # 需要在tushare网站注册获取
    trader = AStockTrader(token)
    strategy = MAStrategy(short_window=5, long_window=20)
    backtest = Backtest(trader, strategy)
    # 运行回测
    # code = "000001.SZ"  # 平安银行
    code = '002342' # 巨力索具
    #code = "002642" 
    backtest.run(code, "20250126", "20250127")
    # 查看交易历史
    print(backtest.trade_history)
    pass
